from PIL import Image
from torch.utils.tensorboard import SummaryWriter

from torchvision import transforms
# transforms : 工具箱-> ToTensor() resize() ..... 对图片进行编辑(初始化)


#如何使用totensor
img_path = "data/微信图片_20231108171009.jpg"
img_PIL = Image.open(img_path) #

writer = SummaryWriter("logs")

tensor_trains = transforms.ToTensor() #先创建totensor工具
tensor_img = tensor_trains(img_PIL) # 再使用

writer.add_image("Tensor_img",tensor_img)
writer.close()


